<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
})->name('home');

Route::namespace('Auth')->group(function (){
    Route::group(['prefix' => 'auth'], function (){
        //退出登入
        Route::post('logout', 'AuthController@logout');
        Route::any('phpinfo', 'AuthController@phpinfo');
        //微信登入
        Route::any('getCode', 'AuthController@getCode');
        //检验Token
        Route::any('check','AuthController@checkToken');
    });
});

Route::namespace('User')->group(function (){
    Route::group(['prefix' => 'users'],function (){
        //用户详情
        Route::any('/{user}/show', 'UserController@show');
        //修改用户信息
        Route::post('/{user}/edit', 'UserController@edit');
        //删除用户
        Route::any('/{user}/destroy','UserController@destroy')->middleware('admin');
        //添加好友
        Route::any('/{user}/follow','UserController@follow');
        //删除好友
        Route::any('/{user}/unfollow','UserController@unfollow');
        //好友列表
        Route::any('/friends','UserController@friendsList');
        //消息列表
        Route::any('/messages','UserController@messageList');
        //手机获取验证码
        Route::post('getCode','UserController@getCode')->middleware('throttle:2,5');
        //验证码校验
        Route::post('verify','UserController@Verify');
    });

    Route::group(['prefix' => 'orders'],function (){
        //创建订单
        Route::post('/create', 'OrderController@create');
        //订单详情
        Route::any('/{order}/show','OrderController@show');
        //接收订单
        Route::any('/{order}/receive','OrderController@receive');
        //订单列表（所有）
        Route::any('/list/{option?}/{sort?}', 'OrderController@list');
        //订单列表（个人）
        Route::any('/mylist/{select?}/{status?}/{option?}', 'OrderController@myList');

        // 软删除 Route::any('/{order}/delete', 'OrderController@delete');
        // 恢复 Route::any('/{order}/restore', 'OrderController@restore');

        //订单销毁
        Route::any('/{order}/destroy', 'OrderController@destroy');
        //订单修改
        Route::post('/{order}/edit', 'OrderController@edit');
        //确定订单
        Route::any('/{order}/confirm','OrderController@confirm');
    });

    Route::group(['prefix' => 'infos'],function (){
        //信息详情
        Route::any('{info}/show','InfoController@show');
        //信息删除
        Route::any('{info}/delete','InfoController@delete');
        //信息列表
        Route::any('{openid}/list/{option?}','InfoController@list');
    });
});

Route::namespace('Manager')->group(function (){
    Route::group(['prefix' => 'managers'],function (){
        Route::get('/login', 'LoginController@index');
        Route::post('/login', 'LoginController@login')->name('login');
        Route::get('/logout', 'LoginController@logout')->name('logout');
        Route::get('/welcome', function (){
            $auth = \Illuminate\Support\Facades\Auth::guard('web')->user();
            return view('manager.welcome',compact('auth'));
        });
        Route::get('/manage','ManagerController@index');
        //资源管理器，对应管理员对订单,用户的操作
        Route::resource('/manage/{option?}', 'ManagerController');
    });
});

